<?php
//ini_set('display_errors',1);
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/javascriptpacker.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/csspacker.php');
$debug=false;
echo("<pre>");
echo("<h1>Javascript</h1>");
echo("<h2>Site</h2>");
$base=__DIR__."/";
//$inputs=array('jquery-1.6.2.rc1.js','json2.js','forms.js','functions.js','tabs.js','jquery.ui.core.js','jquery.ui.widget.js','jquery.ui.mouse.js','jquery.ui.sortable.js','wysiwyg.js','wysiwyg.controls.js','dialogue.js','admin.js','');
	//$output=file_get_contents('jquery-1.5.2.min.js').";";
$inputs=array('jquery-1.6.2.rc1.js','json2.js','forms.js','functions.js','tabs.js','wysiwyg.js','wysiwyg.controls.js','dialogue.js','admin.js','hidden.js','message.js');
	
	foreach($inputs as $input) {
		$script=file_get_contents($base.$input);
	if($debug==false) {
		 $myPacker = new JavaScriptPacker($script, 10, true, false);
 		 $packed = $myPacker->pack();
		
		$output.=$packed.';';
	} else  {
		$output.=$script.';';
	}
		
		echo("Adding $input (".filesize($base.$input)." bytes) to bundle.js \n");
	}
	$op=rtrim($output,";");
	file_put_contents($_SERVER['DOCUMENT_ROOT'].'/admin/resources/client/bundle.js',$op);
unset($output,$op,$packed);


echo("<h1>CSS</h1>");
$cssfiles=array('style.css','tabs.css','wysiwyg.css','dialogue.css');
foreach($cssfiles as $f) {

$file=file_get_contents($base.$f);
$css = CssMin::minify($file);
	$output.=$css;
	echo("Adding $f (".filesize($base.$f)." bytes) to bundle.css\n");
}
file_put_contents($_SERVER['DOCUMENT_ROOT'].'/admin/resources/client/bundle.css',$output);
?>